package com.tanhua.server.interceptor;

import jdk.nashorn.internal.parser.Token;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置类-注册拦截器
 */
@Configuration
@Slf4j
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private TokenInterceptor tokenInterceptor;

    /**
     * 1.将TokenInterceptor注册
     * 2.配置 （拦截路径 + 不拦截路径 ）
     */
    public  void addInterceptors(InterceptorRegistry registry) {
        log.debug("*************InterceptorRegistry**********************");
        registry.addInterceptor(tokenInterceptor)
                .excludePathPatterns("/user/login","/user/loginVerification")
                .addPathPatterns("/**");
    }

}
